<?php 
session_start();

include("../../conexion.php");
	require_once("../../includes/barramenu.php") ;
	require_once("../../includes/gridView.php")  ;
	require_once("../../includes/combo.php")  	  ;
	$oBarra = new BarraMenu() 				  ;
	$Grid1 = new GridView()					  ;
	$oCombo = new CmbList()  				  ;	
	
$id_domiciliario  = $_REQUEST['id_domiciliario'];	
//echo $id_domiciliario; exit();
$consuldomiciliario = mysql_query("
SELECT ubigeo.coddis,
cert_domiciliario.*,tipoestacivil.idestcivil ,
DATE_FORMAT(cert_domiciliario.fec_ingreso,'%d/%m/%Y') AS 'fecingreso2'
FROM cert_domiciliario 
LEFT OUTER JOIN ubigeo ON ubigeo.coddis = cert_domiciliario.distrito_solic
LEFT OUTER JOIN tipoestacivil ON tipoestacivil.idestcivil = cert_domiciliario.idestcivil
WHERE cert_domiciliario.id_domiciliario = '$id_domiciliario'", $conn) or die(mysql_error());
$rowdomic = mysql_fetch_array($consuldomiciliario);
	
$numcarta = $rowdomic['num_certificado'];
$numcarta2 = substr($numcarta,5,6).'-'.substr($numcarta,0,4);

	
?>
<?php 
include("../../conexion.php");
	require_once("../../includes/barramenu.php") ;
	require_once("../../includes/gridView.php")  ;
	require_once("../../includes/combo.php")  	  ;
	$oBarra = new BarraMenu() 				  ;
	$Grid1 = new GridView()					  ;
	$oCombo = new CmbList()  				  ;	
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Certificado Domiciliario</title>
<link href="../../includes/css/jquery-ui-notarios.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../tcal.css" />
<link href="../../includes/css/jquery-ui-notarios.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../includes/css/uniform.default.min.css" />
<link rel="stylesheet" type="text/css" href="../../tcal.css" />

<script type="text/javascript" src="../../tcal.js"></script> 
<script type="text/javascript" src="../includes/Mantenimientos.js"></script> 
<script src="../../includes/jquery-1.8.3.js"></script>
<script src="../../includes/js/jquery-ui-notarios.js"></script>
<script src="../../includes/jquery.uniform.min.js"></script>
<script type="text/javascript" src="../../tcal.js"></script> 

<style type="text/css">
div.carta_content {
	background:#333333;
	border: 1px solid #333333;
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px;
	-moz-box-shadow: 0px 0px 7px #000000;
	-webkit-box-shadow: 0px 0px 7px #000000;
	box-shadow: 0px 0px 7px #000000;
	width:638px;
	height:220px;
	position:absolute;
	left: 549px;
	top: 496px;
	margin-top: 15px;
	margin-left: -450px;
	opacity: 0.95;
	filter: "alpha(opacity=50)"; /* expected to work in IE 8 */
	filter: alpha(opacity=50);   /* IE 4-7 */
	zoom: 1;
}

div.allcontrata {width:600px; height:150px; overflow:auto;}
.titupatrimo {font-size: 12; font-style: italic; font-family: Calibri;}

div.div_bloques
{ 
background-color: #ffffff;
border: 4px solid #264965;  
-moz-border-radius: 13px;
-webkit-border-radius: 13px;
border-radius: 13px;
-moz-box-shadow: 0px 0px 5px #000000;
-webkit-box-shadow: 0px 0px 5px #000000;
box-shadow: 0px 0px 5px #000000;
width:820px; height:750px;
}

.camposss {font-family: Calibri; font-style: italic; font-size: 14px; color: #333333; }


#cabecera{
	margin:0 auto;
	border: 2px solid #ddd; 
	border-radius: 10px; 
	padding: 2px; 
	box-shadow: #ccc 5px 0 5px;
	margin-bottom:0px;
	}
	
	
</style>
<script type="text/javascript">

$(document).ready(function(){ 

	  $("input, textarea").uniform();
	  $("button").button();
	  $("#dialog").dialog();
	})

	function agregar()
	{
		document.getElementById('id_domiciliario').value = '';
		document.getElementById('num_certificado').value = '';
		document.getElementById('fec_ingreso').value = '';
		document.getElementById('num_formu').value = '';
		document.getElementById('nombre_solic').value = '';
		document.getElementById('tipdoc_solic').value = '';
		document.getElementById('numdoc_solic').value = '';
		document.getElementById('domic_solic').value = '';
		document.getElementById('motivo_solic').value = '';
		document.getElementById('distrito_solic').value = '';
		document.getElementById('texto_cuerpo').value = '';
		document.getElementById('justifi_cuerpo').value = '';
	}

	function fGraba(){
		editnnombre_solic();
		editndomic_solic();
		editnnom_testigo();
		 fgrabCertDomic();	}

	function fElimina()
	{ 
		if(confirm('Desea eliminar el certificado..?'))
		{fElimCertDomic(); }
		else {return;}
	}

	function fborrar()
	{
		var _texto_cuerpo   = document.getElementById('texto_cuerpo');
		var _justifi_cuerpo	= document.getElementById('justifi_cuerpo');
		_texto_cuerpo.value = '';
	}

	function fjustificar()
	{
		var _texto_cuerpo   = document.getElementById('texto_cuerpo').value;
		var _justifi_cuerpo	= document.getElementById('justifi_cuerpo').value;
	}


	function fImprimir()
	{
		var _num_crono = document.getElementById('num_certificado').value;
		if(_num_crono==''){alert('Debe guardar los datos primero');return;}
	
		var _usuario_imprime = '<?php echo $_SESSION["apepat_usu"].' '.$_SESSION["nom1_usu"]; ?>';
		var _nom_notario     = 'NOMBRE DEL NOTARIO';
	
	_data =
		{
			num_certificado : _num_crono,
			usuario_imprime : _usuario_imprime,
			nom_notario : _nom_notario,
		}
	
		$.post("../../reportes_word/generador_certifi_domiciliario.php",_data,function(_respuesta){
						alert(_respuesta);
					});
		
	}
	function fVisualDocument()
	{
		var valid_numcrono = document.getElementById('num_certificado').value;
		if(valid_numcrono==''){alert('Debe guardar los datos primero');return;}
		var _num_crono = document.getElementById('muescerti').value;
		
		var _usuario_imprime = '<?php echo $_SESSION["apepat_usu"].' '.$_SESSION["nom1_usu"]; ?>';
		var _nom_notario     = 'NOMBRE DEL NOTARIO';

		window.open("genera_domiciliario.php?num_crono="+_num_crono+"&usuario_imprime="+_usuario_imprime+"&nom_notario="+_nom_notario);				
	}
	

	
	function editnnombre_solic()
	{
		valord=document.getElementById('nnombre_solic').value;
	 	textod=valord.replace(/&/g,"*");
		document.getElementById('nombre_solic').value=textod;
	}
	function editndomic_solic()
	{
		valord=document.getElementById('ndomic_solic').value;
	 	textod=valord.replace(/&/g,"*");
		document.getElementById('domic_solic').value=textod;
	}
	function editnnom_testigo()
	{
		valord=document.getElementById('nnom_testigo').value;
	 	textod=valord.replace(/&/g,"*");
		document.getElementById('nom_testigo').value=textod;
	}
</script>
</head>

<body  style="font-size:62.5%;">
<div id="carta_content">

<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
  <tr><td>
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
	<td>
     <?php
				$oBarra->Graba        = "1"            ;
				$oBarra->GrabaClick   = "fGraba();"    ;
				$oBarra->Impri        = "1"                   ;
				$oBarra->ImpriClick   = "fImprimir();"      ;
				$oBarra->clase        = "css"      		  ; 
				$oBarra->widthtxt     = "20"		      ; 
				$oBarra->Show()  						  ; 
				?>
    </td>
    <td width="77%"><div id="verdocumen"><button title="visualizar" type="button" name="btnver"    id="btnver" value="visualizar" onclick="fVisualDocument();" ><img align="absmiddle" src="../../images/block.png" width="15" height="15" />Ver</button></div></td>
</tr>
</table>
  </td></tr>
  <tr>
    <td ><table  width="100%">
      <tr>
        <td width="13%"><span class="camposss">Nro certificado:</span></td>
        <td width="19%"><input name="num_certificado" type="hidden" id="num_certificado" style="text-transform:uppercase" value="<?php echo $rowdomic['num_certificado']; ?>" size="15" readonly="readonly" />
        <input name="muescerti" type="text" id="muescerti" style="text-transform:uppercase" value="<?php echo $numcarta2; ?>" size="15" readonly="readonly" />
        </td>
        <td width="11%"><span class="camposss">Fecha Ingreso:</span> </td>
        <td width="23%"><input name="fec_ingreso" type="text" id="fec_ingreso" style="text-transform:uppercase" value="<?php echo $rowdomic['fecingreso2']; ?>" size="15" class="tcal" /></td>
        <td width="14%"># Formulario:</td>
        <td width="20%"><input name="num_formu" type="text" id="num_formu" style="text-transform:uppercase" value="<?php echo $rowdomic['num_formu']; ?>" size="15" /></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    <fieldset>
    <legend><strong><span class="camposss">SOLICITANTE</span></strong></legend>
    <table  width="100%">
        <tr>
          <td width="9%"><span class="camposss">Solicitante:</span></td>
          <td colspan="3"><input name="nnombre_solic" type="text" id="nnombre_solic" onKeyUp="editnnombre_solic();" style="text-transform:uppercase" value="<?php 
		   $c_desc = $rowdomic['nombre_solic'];
		 	 $textorpat=str_replace("?","'",$c_desc);
		 	 $textoamperpat=str_replace("*","&",$textorpat);
		 	 echo strtoupper($textoamperpat); ?>" size="100" maxlength="400" />
             <input type="hidden" name="nombre_solic" id="nombre_solic" />
             </td>
          </tr>
        <tr>
          <td><span class="camposss">Identificado con:</span></td>
          <td width="25%" colspan="-1"><?php 
			$oCombo = new CmbList()  ;					 		
			$oCombo->dataSource = "SELECT tipodocumento.codtipdoc AS 'id', tipodocumento.destipdoc AS 'des'
FROM tipodocumento
ORDER BY tipodocumento.destipdoc ASC"; 
			$oCombo->value      = "id";
			$oCombo->text       = "des";
			$oCombo->size       = "200"; 
			$oCombo->name       = "tipdoc_solic";
			$oCombo->style      = "camposss"; 
			$oCombo->click      = "//selectAsunto(this.value);";   
			$oCombo->selected   =  $rowdomic['tipdoc_solic'];
			$oCombo->Show();
			$oCombo->oDesCon(); 
?></td>
          <td width="10%" colspan="-1" align="right"><span class="camposss">Nro.</span></td>
          <td width="56%" colspan="-1"><input name="numdoc_solic" type="text" id="numdoc_solic" style="text-transform:uppercase" value="<?php echo $rowdomic['numdoc_solic']; ?>" size="15" maxlength="20" /></td>
        </tr>
        <tr>
          <td><span class="camposss">Domicilio:</span></td>
          <td colspan="3"><input name="ndomic_solic" type="text" id="ndomic_solic" onKeyUp="editndomic_solic();" style="text-transform:uppercase" value="<?php 
		   $c_desc = $rowdomic['domic_solic'];
		 	 $textorpat=str_replace("?","'",$c_desc);
		 	 $textoamperpat=str_replace("*","&",$textorpat);
		 	 echo strtoupper($textoamperpat); ?>" size="100" maxlength="2000" />
              <input type="hidden" name="domic_solic" id="domic_solic" />
             </td>
          </tr>
        <tr>
          <td><span class="camposss">Distrito:</span></td>
          <td colspan="3"><?php 
			$oCombo = new CmbList()  ;					 		
			$oCombo->dataSource = "SELECT ubigeo.coddis AS 'id',  CONCAT(ubigeo.nomdis,'/', ubigeo.nomprov,'/',ubigeo.nomdpto)  AS 'descripcion' FROM ubigeo
ORDER BY ubigeo.nomdis ASC"; 
			$oCombo->value      = "id";
			$oCombo->text       = "descripcion";
			$oCombo->size       = "150"; 
			$oCombo->name       = "distrito_solic";
			$oCombo->style      = "camposss"; 
			$oCombo->click      = "//selectzona(this.value);";   
			$oCombo->selected   =  $rowdomic['coddis'];
			$oCombo->Show();
			$oCombo->oDesCon(); 
?></td>
          </tr>
        <tr>
          <td><span class="camposss">Motivo:</span></td>
          <td colspan="3"><input name="motivo_solic" type="text" id="motivo_solic" style="text-transform:uppercase" value="<?php echo $rowdomic['motivo_solic']; ?>" size="100" maxlength="2000" /></td>
          </tr>
          
          <tr>

    <td height="30" align="right"><span class="camposss">Estado Civil :</span></td>
    <td height="30"><?php 
			$oCombo = new CmbList()  ;					 		
			$oCombo->dataSource = "SELECT tipoestacivil.idestcivil AS 'id',  CONCAT(tipoestacivil.desestcivil)  AS 'descripcion' FROM tipoestacivil
ORDER BY tipoestacivil.desestcivil ASC"; 
			$oCombo->value      = "id";
			$oCombo->text       = "descripcion";
			$oCombo->size       = "150"; 
			$oCombo->name       = "idestcivil";
			$oCombo->style      = "camposss"; 
			$oCombo->click      = "//selectzona(this.value);";   
			$oCombo->selected   =  $rowdomic['idestcivil'];
			$oCombo->Show();
			$oCombo->oDesCon(); 
?>
</td>
  </tr>
  <tr>

    <td height="30" align="left"><span class="camposss">Sexo :</span></td>
    
    
    <td height="30"><select name="sexo" id="sexo">
     <?php echo "<option  selected='selected'>"; 
	 if ($rowdomic['sexo']=="M"){
	 echo "MASCULINO";
	 }else if($rowdomic['sexo']=="F"){
		  echo "FEMENINO";
	 }
	 echo"</option>";?>
      <option value="M">MASCULINO</option>
      <option value="F">FEMENINO</option>
    </select></td>
    <td height="30" align="right">&nbsp;</td>
    <td height="30">&nbsp;</td>
  </tr>
        </table>
    </fieldset>  
      </td>
    </tr>
  <tr>
    <td height="30"><fieldset>
      <legend><strong>CUERPO</strong></legend>
      <table  width="100%">
        <tr>
          <td width="9%"><button title="Borrar" type="button" name="borrar"    id="borrar" value="borrar" onclick="fborrar();" ><img src="../../images/eraser.png" width="25" height="25" align="absmiddle" /></br>&nbsp;&nbsp;Borrar&nbsp;&nbsp;</button></td>
          <td><label for="texto_cuerpo"></label>
            <textarea style="text-transform:uppercase;" name="texto_cuerpo" id="texto_cuerpo" cols="95" rows="5"><?php echo $rowdomic['texto_cuerpo']; ?></textarea></td>
        </tr>
        <tr>
        <td colspan="6"><span class="camposss">Testigo a ruego:
              <input name="nnom_testigo" type="text" id="nnom_testigo" onKeyUp="editnnom_testigo();" style="text-transform:uppercase" value="<?php 
			  $c_desc = $rowdomic['nom_testigo'];
		 	 $textorpat=str_replace("?","'",$c_desc);
		 	 $textoamperpat=str_replace("*","&",$textorpat);
		 	 echo strtoupper($textoamperpat); ?>" size="80" maxlength="400" />
          </span>
           <input type="hidden" name="nom_testigo" id="nom_testigo" />
          </td>
        </tr>
        
        <tr>
         <td><span class="camposss">Identificado con:</span></td>
          <td><?php 
			$oCombo = new CmbList()  ;					 		
			$oCombo->dataSource = "SELECT tipodocumento.codtipdoc AS 'id', tipodocumento.destipdoc AS 'des'
FROM tipodocumento
ORDER BY tipodocumento.destipdoc ASC"; 
			$oCombo->value      = "id";
			$oCombo->text       = "des";
			$oCombo->size       = "200"; 
			$oCombo->name       = "tdoc_testigo";
			$oCombo->style      = "camposss"; 
			$oCombo->click      = "//selectAsunto(this.value);";   
			$oCombo->selected   =  "01";
			$oCombo->Show();
			$oCombo->oDesCon(); 
?></td>
          <td align="right"><span class="camposss">Nro.</span></td>
          <td><input name="ndocu_testigodom" type="text" id="ndocu_testigodom" style="text-transform:uppercase" value="<?php echo $rowdomic['ndocu_testigo']; ?>" size="15" maxlength="20" placeholder="N. documento" /></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2"><input name="justifi_cuerpo" type="hidden" id="justifi_cuerpo" value="<?php echo $rowdomic['justifi_cuerpo']; ?>" /></td>
        </tr>
        <tr>
          <td colspan="2"><input name="id_domiciliario" type="hidden" id="id_domiciliario" value="<?php echo $rowdomic['id_domiciliario']; ?>" /></td>
          </tr>
        </table>
    </fieldset></td>
  </tr>
</table>
</div>
</body>
</html>